package ca.starfarer.kobold.model;

/**
 * A damage amount and type.
 *
 * @author Kevin
 */
public class Damage {

    // TODO: Need to handle damage that is part one type (or untyped) and part another eg. "12 plus 5 fire damage"

    private final int value;

    private final DamageType type;

    public Damage(int value) {
        this(value, null);
    }

    public Damage(int value, DamageType type) {
        if (value < 0) {
            throw new IllegalArgumentException("Value must be >= 0");
        }
        this.value = value;
        this.type = type;
    }

    public int getValue() {
        return value;
    }

    public DamageType getType() {
        return type;
    }

    @Override
    public String toString() {
        StringBuffer buf = new StringBuffer();
        buf.append(value);
        if (type != null) {
            buf.append(' ').append(type);
        }
        return buf.toString();
    }
}
